package com.yuan.Controller.user;


import com.yuan.Service.OrderService;
import com.yuan.dto.OrdersSubmitDTO;
import com.yuan.result.Result;
import com.yuan.vo.OrderSubmitVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController("/user/order")
@RequestMapping
@RequiredArgsConstructor
@Slf4j
@Tag(name = "用户端订单相关接口 ")
public class OrderController {


    private final OrderService orderService;


    //用户下单
    @PostMapping("/submit")
    @Operation(description = "用户下单")
    public Result<OrderSubmitVO> submit(@RequestBody
                                        OrdersSubmitDTO ordersSubmitDTO) {
        log.info("用户下单，参数为：{}", ordersSubmitDTO);
        OrderSubmitVO orderSubmitVO = orderService.submitOrder(ordersSubmitDTO);
        return Result.success(orderSubmitVO);
    }

}
